// src/store/index.ts
import { createStore } from 'vuex';
import cartModule from './modules/cartModule';
import userModule from './modules/userModule';
import type { CartState, UserState } from '@/types';

// 手动定义 RootState 类型
export interface RootState {
  cart: CartState
  user: UserState
}

export default createStore<RootState>({
  modules: {
    cart: cartModule,
    user: userModule
  },
  getters: {
    token(state): string | undefined {
      return state.user.userInfo.token;
    }
  }
});